use "C:\Users\chance\Desktop\0707\Impact of PFTZ on LGQ data.dta"

////tab3
summarize LGQ pftz mkt rtl tal open urban inds gdpd dig
///tab4 
xtreg  f1.LGQ pftz  ,fe
est sto a1
xtreg  f1.LGQ pftz i.year ,fe
est sto a2
xtreg  f1.LGQ pftz open urban inds gdpd dig ,fe
est sto a3
xtreg  f1.LGQ pftz open urban inds gdpd dig  i.year,fe
est sto a4
esttab a* using a1.rtf,keep(pftz open urban inds gdpd dig  _cons) order(pftz open urban inds gdpd dig  _cons) star(* 0.1 ** 0.05 *** 0.01) b(%6.3f) se(%6.3f) nogaps r2

///fig3
xtreg  f1.LGQ pre5 pre4 pre3 pre2 current post1 post2 post3 post4 post5 open urban  inds  gdpd  dig  i.year,fe
 coefplot, vertical keep( pre5 pre4 pre3 pre2 current post1 post2 post3 post4 post5）omited order（pre5 pre4 pre3 pre2 current post1 post2 post3 post4 post5 ) ciopt(recast(rcap) lcolor(black)) mcolor(black)  recast(connect) xline(5)
  
///tab5
xtreg f1.LGQ ftzp2 open urban inds gdpd dig i.year ,fe
  est sto f2
xtreg f1.LGQ ftzp3 open urban inds gdpd dig i.year ,fe
  est sto f3
xtreg f1.LGQ pftz open urban inds gdpd dig obori i.year,fe
 est sto f4
xtreg f1.LGQ pftz open urban inds gdpd dig obori yebi i.year ,fe
 est sto f5
xtreg f1.LGQ lnftzarea open urban inds gdpd dig i.year,fe
est sto f6
xtgls f1.LGQ pftz open urban inds gdpd dig i.year i.id, panels(correlated)
 est sto f7
esttab f* using f.rtf,keep(pftz ftzp2 ftzp3 obori yebi lnftzarea  _cons) order(pftz ftzp2 ftzp3 obori yebi lnftzarea _cons) star(* 0.1 ** 0.05 *** 0.01) b(%6.3f) se(%6.3f) nogaps r2

///tab6
xtreg pftz Distance open urban inds gdpd dig i.year if year<2020,fe
est sto ivs1
ivregress 2sls f1.LGQ open urban inds gdpd dig i.id i.year (pftz =Distance),first 
est sto iv1
esttab ivs1 iv1  using iv.rtf, keep( pftz Distance _cons) order( pftz Distance _cons) star(* 0.1 ** 0.05 *** 0.01) b(%6.3f)  se(%6.3f) nogaps r2

 ///tab7
xtreg  f1.LGQ c.coaa#c.pftz c.coab#c.pftz pftz  open urban inds gdpd dig,fe
est sto b1
xtreg  f1.LGQ c.coaa#c.pftz c.coab#c.pftz pftz  open urban inds gdpd dig i.year,fe
est sto b2
xtreg  f1.LGQ  pftz c.pftzsecond#c.pftz c.pftzthird#c.pftz c.pftzforth#c.pftz  open urban inds gdpd dig,fe
est sto b3
xtreg  f1.LGQ pftz c.pftzsecond#c.pftz c.pftzthird#c.pftz c.pftzforth#c.pftz  open urban inds gdpd dig i.year,fe
est sto b4
esttab b* using b.rtf,keep(pftz c.coaa#c.pftz c.coab#c.pftz  c.pftzsecond#c.pftz c.pftzthird#c.pftz c.pftzforth#c.pftz  _cons) order(pftz c.coaa#c.pftz c.coab#c.pftz  c.pftzsecond#c.pftz c.pftzthird#c.pftz c.pftzforth#c.pftz _cons) star(* 0.1 ** 0.05 *** 0.01) b(%6.3f) se(%6.3f) nogaps r2

 ///tab8
xtreg mkt pftz open urban inds gdpd dig i.year,fe
est sto e1
xtreg f1.LGQ mkt pftz open urban inds gdpd dig i.year,fe
est sto e2
xtreg rtl pftz open urban inds gdpd dig i.year,fe
est sto e3
xtreg f1.LGQ rtl pftz open urban inds gdpd dig i.year,fe
est sto e4
xtreg tal pftz open urban inds gdpd dig i.year,fe
est sto e5
xtreg f1.LGQ tal pftz open urban inds gdpd dig i.year,fe
est sto e6
esttab e* using e3.rtf,keep(pftz mkt rtl tal  _cons) order(pftz mkt rtl tal _cons) star(* 0.1 ** 0.05 *** 0.01) b(%6.3f) se(%6.3f) nogaps r2
 
///tab9
xtreg f1.LGQ FDI pftz open urban inds gdpd dig i.year ,fe
est sto c3
xtreg f1.LGQ c.FDI#c.pftz FDI pftz open urban inds gdpd dig i.year,fe
est sto c4
esttab c* using cc.rtf,keep(pftz FDI c.FDI#c.pftz _cons) order(pftz FDI c.FDI#c.pftz  _cons) star(* 0.1 ** 0.05 *** 0.01) b(%6.3f) se(%6.3f) nogaps r2
 
///tab10
xtreg f1.LGQ gp pftz open urban inds gdpd dig i.year,fe
est sto dd1
xtreg f1.LGQ c.gp#c.pftz gp pftz open urban inds gdpd dig i.year,fe
est sto dd2
esttab dd* using add.rtf,keep(pftz gp c.gp#c.pftz _cons) order(pftz gp c.gp#c.pftz _cons) star(* 0.1 ** 0.05 *** 0.01) b(%6.3f) se(%6.3f) nogaps r2
 

///fig4 
gen FLGQ=f1.LGQ
permute pftz beta = _b[pftz], reps(500) seed(100)  saving("spftz.dta"):xtreg FLGQ pftz open urban inds gdpd dig i.year,fe

//// open a new stata window and run the code as below.
clear
use "spftz.dta", clear
dpplot beta, xline(0.005, lc(black*1.2) lp(dash)) xline(0, lc(black*0.5) lp(solid)) xtitle("Estimator", size(*1.2))  xlabel(-0.01(10)0.01, labsize(small)) ytitle("Density", size(*1.2))  ylabel(, nogrid format(%4.1f) labsize(small))  note("") caption("") graphregion(fcolor(white))



